﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1060001, 0),
Array("", 1060003, 0),
Array("", 1060034, 0),
Array("", 1060035, 0),
Array("", 1060036, 0),
Array("", 1060040, 0),
Array("", 1060041, 0),
Array("", 1060042, 0),
Array("", 1060047, 0),
Array("", 1060048, 0),
Array("", 1060049, 0),
Array("", 1060053, 0),
Array("", 1060054, 0),
Array("", 1060055, 0),
Array("", 1060066, 0),
Array("", 1060067, 0),
Array("", 1060096, 0),
Array("", 1060103, 0),
Array("", 1060108, 0),
Array("", 1060112, 0),
Array("", 1060113, 0),
Array("", 1060114, 0),
Array("", 1060116, 0),
Array("", 1060117, 0),
Array("", 1060118, 0),
Array("", 1060119, 0),
Array("", 1060120, 0),
Array("", 1060121, 0),
Array("", 1060122, 0),
Array("", 1060123, 0),
Array("", 1060126, 0),
Array("", 1060145, 0),
Array("", 1060174, 0),
Array("", 1061000, 0),
Array("", 1061001, 0),
Array("", 1061004, 0),
Array("", 1061005, 0),
Array("", 1061007, 0),
Array("", 1061065, 0),
Array("", 1061066, 0),
Array("", 1061067, 0),
Array("", 1061068, 0),
Array("", 1061072, 0),
Array("", 1061073, 0),
Array("", 1061074, 0),
Array("", 1061075, 0),
Array("", 1061089, 0),
Array("", 1061103, 0),
Array("", 1061107, 0),
Array("", 1061108, 0),
Array("", 1061109, 0),
Array("", 1061110, 0),
Array("", 1061111, 0),
Array("", 1061112, 0),
Array("", 1061113, 0),
Array("", 1061124, 0),
Array("", 1061126, 0),
Array("", 1061127, 0),
Array("", 1061128, 0),
Array("", 1061129, 0),
Array("", 1061130, 0),
Array("", 1061131, 0),
Array("", 1061132, 0),
Array("", 1061133, 0),
Array("", 1061134, 0),
Array("", 1061135, 0),
Array("", 1061136, 0),
Array("", 1061137, 0),
Array("", 1061138, 0),
Array("", 1061139, 0),
Array("", 1061140, 0),
Array("", 1061141, 0),
Array("", 1061142, 0),
Array("", 1061144, 0),
Array("", 1061145, 0),
Array("", 1061148, 0),
Array("", 1061161, 0),
Array("", 1061166, 0),
Array("", 1061170, 0),
Array("", 1061198, 0),
Array("", 1061199, 0),
Array("", 1062003, 0),
Array("", 1062005, 0),
Array("", 1062008, 0),
Array("", 1062009, 0),
Array("", 1062010, 0),
Array("", 1062011, 0),
Array("", 1062012, 0),
Array("", 1062013, 0),
Array("", 1062014, 0),
Array("", 1062015, 0),
Array("", 1062016, 0),
Array("", 1062017, 0),
Array("", 1062018, 0),
Array("", 1062019, 0),
Array("", 1062020, 0),
Array("", 1062021, 0),
Array("", 1062022, 0),
Array("", 1062023, 0),
Array("", 1062024, 0),
Array("", 1062025, 0),
Array("", 1062026, 0),
Array("", 1062027, 0),
Array("", 1062028, 0),
Array("", 1062031, 0),
Array("", 1062032, 0),
Array("", 1062033, 0),
Array("", 1062034, 0),
Array("", 1062035, 0),
Array("", 1062038, 0),
Array("", 1062039, 0),
Array("", 1062040, 0),
Array("", 1062041, 0),
Array("", 1062042, 0),
Array("", 1062043, 0),
Array("", 1062044, 0),
Array("", 1062045, 0),
Array("", 1062046, 0),
Array("", 1062047, 0),
Array("", 1062048, 0),
Array("", 1062051, 0),
Array("", 1062052, 0),
Array("", 1062053, 0),
Array("", 1062054, 0),
Array("", 1062055, 0),
Array("", 1062056, 0),
Array("", 1062057, 0),
Array("", 1062058, 0),
Array("", 1062059, 0),
Array("", 1062060, 0),
Array("", 1062061, 0),
Array("", 1062062, 0),
Array("", 1062063, 0),
Array("", 1062064, 0),
Array("", 1062065, 0),
Array("", 1062066, 0),
Array("", 1062067, 0),
Array("", 1062068, 0),
Array("", 1062069, 0),
Array("", 1062070, 0),
Array("", 1062071, 0),
Array("", 1062072, 0),
Array("", 1062073, 0),
Array("", 1062074, 0),
Array("", 1062075, 0),
Array("", 1062076, 0),
Array("", 1062077, 0),
Array("", 1062080, 0),
Array("", 1062081, 0),
Array("", 1062082, 0),
Array("", 1062083, 0),
Array("", 1062084, 0),
Array("", 1062085, 0),
Array("", 1062086, 0),
Array("", 1062087, 0),
Array("", 1062088, 0),
Array("", 1062089, 0),
Array("", 1062091, 0),
Array("", 1062092, 0),
Array("", 1062093, 0),
Array("", 1062094, 0),
Array("", 1062095, 0),
Array("", 1062096, 0),
Array("", 1062097, 0),
Array("", 1062098, 0),
Array("", 1062100, 0),
Array("", 1062101, 0),
Array("", 1062102, 0),
Array("", 1062103, 0),
Array("", 1062104, 0),
Array("", 1062105, 0),
Array("", 1062106, 0),
Array("", 1062107, 0),
Array("", 1062108, 0),
Array("", 1062109, 0),
Array("", 1062110, 0),
Array("", 1062111, 0),
Array("", 1062112, 0),
Array("", 1062113, 0),
Array("", 1062114, 0),
Array("", 1062116, 0),
Array("", 1062118, 0),
Array("", 1062119, 0),
Array("", 1062121, 0),
Array("", 1062122, 0),
Array("", 1062123, 0),
Array("", 1062124, 0),
Array("", 1062126, 0),
Array("", 1062129, 0),
Array("", 1062130, 0),
Array("", 1062131, 0),
Array("", 1062133, 0),
Array("", 1062134, 0),
Array("", 1062135, 0),
Array("", 1062136, 0),
Array("", 1062137, 0),
Array("", 1062138, 0),
Array("", 1062139, 0),
Array("", 1062145, 0),
Array("", 1062147, 0),
Array("", 1062151, 0),
Array("", 1062152, 0),
Array("", 1062153, 0),
Array("", 1062154, 0),
Array("", 1062155, 0),
Array("", 1062156, 0),
Array("", 1062157, 0),
Array("", 1062163, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n消费币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d消费币#k#l";
            }
            cm.sendSimpleS("欢迎来到时尚裤子店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的消费币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}